<?php

namespace app\common\service\order\coupon_order\movie;

use app\common\service\order\coupon_order\Base;
use app\common\service\order\coupon_order\CouponOrderChannelInterface;
use app\model\AgentServiceConfig;
use app\model\CouponOrder;
use Carbon\Carbon;

abstract class MovieBase extends Base implements CouponOrderChannelInterface
{


    /**
     * 同步订单
     * @return mixed
     */
    abstract public function syncOrder();


    /**
     * 类型 常量类型
     * @return mixed
     */
    abstract public function getServType();

    /**
     * 产品名称 可以是title
     * @return mixed
     */
    abstract public function getProductName();

    /**
     * 产品图标
     * @return mixed
     */
    abstract public function getProductImage();


    /**
     *  获取结算状态
     * @return mixed
     */
    abstract public function getAgentSettleStatus();

    /**
     * 获取状态
     * @return mixed
     */
    abstract public function getStatus();


    public function getSupplierOrderSn()
    {

        return $this->params['order_id'] ?? '';

    }

    public function getAmount()
    {
        return $this->params['sale_price'] ?? 0;
    }


    /**
     * 平台利润
     */
    public function getPlatformProfit()
    {
        return $this->params['platform_profit'];
    }

    /**
     * @return mixed
     */
    public function getSupplierPrice()
    {

        return $this->params['supplier_price'];

    }

    /**
     *
     */
    public function getSettlePrice()
    {

        return $this->params['supplier_price'];

    }


    public function getOrderAllCommission()
    {
        $profit = $this->params['profit'] ?? 0;

        return fen2yuan($profit);
    }

    public function getAgentId()
    {
        return $this->params['agent_id'];
    }

    public function getOriginAmount()
    {
        return $this->params['total_net_price'];
    }

    public function getPayAmount()
    {
        return $this->amount;
    }

    public function getPayStatus()
    {
        //拉取的都是已支付的
        return CouponOrder::C_PAY_STATUS_YES;
    }

    /**
     * 代理商利润
     */
    public function getProfit()
    {

        return $this->params['profit'];

    }

    /**
     * 代理结算比例
     */
    public function getAgentSettleDiscount()
    {
        return $this->params['commission_rate'];
    }

    public function getPayTime()
    {

        $pay_time = $this->params['pay_time'] != 0 ? $this->params['pay_time'] : strtotime($this->params['created_at']);

        return date('Y-m-d H:i:s', $pay_time);
    }

    public function getUserId()
    {
        return $this->params['user_id'];
    }

    public function getStatusDesc()
    {
        return '';
    }

    public function getSettledAt()
    {
        //不涉及这边结算
        return null;
    }

    public function getType()
    {
        return 0;//没啥子类型
    }

    public function getCnid()
    {
        return $this->params['channel_id'];
    }

    public function getSettleType()
    {
        return SETTLE_TYPE_PROFIT;
    }

    public function getExtData()
    {
        return [
            'ticket_code' => json_decode($this->params['ticket_code'], true),
            'ticket_image' => json_decode($this->params['ticket_image'], true),
        ];
    }

    public function getOrderCreatedAt()
    {
        return $this->params['created_at'];

        return $this->pay_time;
    }

    public function getTitle()
    {
        return $this->params['film_name'] . $this->params['cinema_name'] . $this->params['seats_str'];
    }

    /**
     * 退款金额
     */
    public function getRefundAmount()
    {
        return $this->params['refund_amount'];
    }

    public function getRefundStatus()
    {
        //退款状态
        if ($this->params['refund_status'] == 3) {
            return CouponOrder::C_REFUND_STATUS_HAVE;
        }
        return CouponOrder::C_REFUND_STATUS_NO;
    }

    /**
     * sid
     */
    public function getSid()
    {
        return $this->params['sid'] ?? '';
    }

    /**
     * 公共start
     * 本地存储订单号 自由发挥
     */
    public function getOrderId()
    {

        return $this->params['order_id'];

    }

    public function getOutOrderId()
    {
        return !empty($this->params['supplier_order_id']) ? $this->params['supplier_order_id'] : $this->supplier_order_sn;
    }

    public function getMobile()
    {
        return $this->params['mobile'];
    }

    public function getQuoteId()
    {
        return $this->params['id'];
    }

}